package com.hsgene.order.condition;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.hsgene.common.util.date.SimpleDateUtils;
import com.hsgene.common.util.date.TimeJsonDeserializer;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * @description:
 * @projectName: hdas-geneshop-server
 * @package: com.hsgene.product.dto
 * @author: maodi
 * @createDate: 2018/11/1 14:07
 * @version: 1.0
 * Copyright: Copyright (c) 2018
 */
public class QueryTestingProductOrderCondition implements Serializable {

    private static final long serialVersionUID = 4839105857076454901L;

    /**
     * 检测编号
     */
    private String orderNo;

    /**
     * 地服姓名
     */
    private String groundServantName;

    /**
     * 患者姓名
     */
    private String patientName;

    /**
     * 医生电话
     */
    private String doctorPhone;

    /**
     * 样本条码
     */
    private String sampleBarcode;

    /**
     * 订单状态
     */
    private String status;

    /**
     * 下单开始时间
     */
    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date startDate;

    /**
     * 下单结束时间
     */
    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date endDate;

    /**
     * 检测机构名称
     */
    private String agencyName;

    /**
     * 检测机构id
     */
    private String agencyId;

    /**
     * 订单来源
     */
    private String orderOrigin;

    /**
     * 是否特殊标记(0-未标记，1-标记，2-确认标记)
     */
    private Integer sign;

    /**
     * 首单奖励(0-不满足首单奖励,1-首单奖励未发,2-首单奖励已发)
     */
    private Integer awardSingle;

    /**
     * 排序字段
     */
    private String sortField;

    /**
     * 排序类型
     */
    private String sortType;

    /**
     * 付费状态
     */
    private String chargeStatus;

    /**
     * 更换套餐状态
     */
    private Integer changePackage;

    /**
     * 是否开票
     */
    private Integer invoiceInquiry;

    /**
     * 是否查询不超期
     */
    private Integer isQueryNotPostpone = 0;

    public QueryTestingProductOrderCondition() {
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getGroundServantName() {
        return groundServantName;
    }

    public void setGroundServantName(String groundServantName) {
        this.groundServantName = groundServantName;
    }

    public String getPatientName() {
        return patientName;
    }

    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }

    public String getDoctorPhone() {
        return doctorPhone;
    }

    public void setDoctorPhone(String doctorPhone) {
        this.doctorPhone = doctorPhone;
    }

    public String getSampleBarcode() {
        return sampleBarcode;
    }

    public void setSampleBarcode(String sampleBarcode) {
        this.sampleBarcode = sampleBarcode;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getStartDate() {
        return startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public String getAgencyName() {
        return agencyName;
    }

    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }

    public String getOrderOrigin() {
        return orderOrigin;
    }

    public void setOrderOrigin(String orderOrigin) {
        this.orderOrigin = orderOrigin;
    }

    private Date string2Date(String str) {
        if (TimeJsonDeserializer.matchStandardPattern(str)) {
            return SimpleDateUtils.parseDate(str, SimpleDateUtils.DatePattern.STANDARD_PATTERN.toString());
        } else {
            return SimpleDateUtils.parseDate(str, SimpleDateUtils.DatePattern.YYYY_MM_DD.toString(), SimpleDateUtils
                    .HourMinSecondFormat.MID_NIGHT);
        }
    }

    public Integer getSign() {
        return sign;
    }

    public void setSign(Integer sign) {
        this.sign = sign;
    }

    public Integer getAwardSingle() {
        return awardSingle;
    }

    public void setAwardSingle(Integer awardSingle) {
        this.awardSingle = awardSingle;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getSortType() {
        return sortType;
    }

    public void setSortType(String sortType) {
        this.sortType = sortType;
    }

    public String getChargeStatus() {
        return chargeStatus;
    }

    public void setChargeStatus(String chargeStatus) {
        this.chargeStatus = chargeStatus;
    }

    public String getAgencyId() {
        return agencyId;
    }

    public void setAgencyId(String agencyId) {
        this.agencyId = agencyId;
    }

    public Integer getChangePackage() {
        return changePackage;
    }

    public void setChangePackage(Integer changePackage) {
        this.changePackage = changePackage;
    }

    public Integer getInvoiceInquiry() {
        return invoiceInquiry;
    }

    public void setInvoiceInquiry(Integer invoiceInquiry) {
        this.invoiceInquiry = invoiceInquiry;
    }

    public void setStartDate(String startDateStr) {
        if (StringUtils.isNotBlank(startDateStr)) {
            if (TimeJsonDeserializer.matchStandardPattern(startDateStr)) {
                this.startDate = SimpleDateUtils.parseDate(startDateStr, SimpleDateUtils.DatePattern.STANDARD_PATTERN
                        .toString());
            } else {
                this.startDate = SimpleDateUtils.parseDate(startDateStr, SimpleDateUtils.DatePattern.YYYY_MM_DD.toString
                        (), SimpleDateUtils.HourMinSecondFormat.MID_NIGHT);
            }
        }
    }

    public void setEndDate(String endDateStr) {
        if (StringUtils.isNotBlank(endDateStr)) {
            if (TimeJsonDeserializer.matchStandardPattern(endDateStr)) {
                this.endDate = SimpleDateUtils.parseDate(endDateStr, SimpleDateUtils.DatePattern.STANDARD_PATTERN
                        .toString());
            } else {
                this.endDate = SimpleDateUtils.parseDate(endDateStr, SimpleDateUtils.DatePattern.YYYY_MM_DD.toString(),
                        SimpleDateUtils.HourMinSecondFormat.TODAY_END);
            }
        }
    }

    public Integer getIsQueryNotPostpone() {
        return isQueryNotPostpone;
    }

    public void setIsQueryNotPostpone(Integer isQueryNotPostpone) {
        this.isQueryNotPostpone = isQueryNotPostpone;
    }
}
